<template>
	<u-navbar :leftIconSize="42" titleStyle="font-size:20px;font-weight:600" :autoBack="true" :placeholder='true'
		title="设置"> </u-navbar>
	<view class="padding-30rpx">
		<view class="white-bg bg-border-8px" style="margin-top: 15px;border-radius: 8px;padding: 0 15px">
			<view class="flex-jc-s-b padding-30rpx" :class="index!==data['cellList'].length-1?' mine-cell': ''"
				style="padding: 15px 0" v-for="(item,index) in data['cellList']" @click="settingHandle(item)">
				<text style="color:#333333 ;font-size: 15px;">{{item.title}}</text>
				<u-icon size="24" name="arrow-right"></u-icon>
			</view>
		</view>
	</view>
	<!-- 联系客服 -->
  <server ref="serverRef"></server>
	<view class="flex-center" style="position: fixed;width: 100%; bottom: 30px;">
		<view class="butView" @click="exitAction">
			退出登录
		</view>
	</view>
</template>
<script setup>
  import { saleLogout } from '@/api/login.js'
	import { ref, reactive, getCurrentInstance } from "vue";
  import server from './components/server.vue'
  const { proxy } = getCurrentInstance()
  const serverRef = ref('')
	const data = reactive({
		show: false,
		cellList: [
      {
        title: '提现账号管理',
        path: 'pages/withdrawal/account/query',
        type: 'withdrawal',
        params: {
          code: 'edit'
        }
      },
      {
        title: '修改密码',
        path: 'pages/login/components/forget-password',
        type: 'password',
        params: {
          code: 'edit'
        }
      },
      {
        title: '联系客服',
        path: '',
        type: 'service'
      },
		]
	})
	const settingHandle = (item) => {
		if (item.type === 'service') {
      serverRef.value.show = true
    } else {
      proxy.$routePage({url: item.path, params: item.params})
    }
	}
	const exitAction = () => {
		saleLogout({ sessionKey: uni.getStorageSync('token') }).then((res) => {
			if (res.code == 200) {
				uni.showToast({
					mask: true,
					title: res.msg,
					duration: 1200,
					icon: 'none'
				})
				uni.removeStorageSync('token');
				uni.$u.route({
					type: 'redirect',
					url: 'pages/login/login'
				})
			}
		})
	}
</script>

<style lang="scss" scoped>
	.mine-cell {
		border-bottom: 1px solid rgba(0, 0, 0, 0.1);
	}

	.service-content {
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		padding: 20px;
		color: #333333;
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 345px;
		height: 360px;
		background: #FFFFFF;
		border-radius: 8px
	}

	.butView {
		width: 345px;
		background: #EB5940;
		height: 45px;
		border-radius: 40px;
		font-size: 16px;
		line-height: 45px;
		font-weight: bold;
		color: #FFFFFF;
		text-align: center;
	}
</style>
